package com.shaozi.nc.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.shaozi.lib.execpool.RunnableExecutor;

@Configuration
public class RunnableConfiguration {
	@Value("${runExecutor.queueCapacity}")
	private int queueCapacity;

	@Value("${runExecutor.minThread}")
	private int minThread;

	@Value("${runExecutor.maxThread}")
	private int maxThread;

	/**
	 * <bean id="runExecutor" class="com.shaozi.lib.execpool.RunnableExecutor"
	 * init-method="startService" destroy-method="shutdown">
	 * <property name= "queueCapacity" value=
	 * "${runExecutor.queueCapacity}"></property>
	 * <property name="minThread" value="${runExecutor.minThread}"></property>
	 * <property name="maxThread" value="${runExecutor.maxThread}"></property>
	 * </bean>
	 * 
	 * @return
	 */
	@Bean(name = "runnableExecutor")
	public RunnableExecutor getRunnableExecutor() {
		RunnableExecutor runnableExecutor = new RunnableExecutor();
		runnableExecutor.setMaxThread(maxThread);
		runnableExecutor.setMinThread(minThread);
		runnableExecutor.setQueueCapacity(queueCapacity);
		return runnableExecutor;
	}

}
